home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekkan Dennou Club 147
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan).7z
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan) (Track 1).bin
/
docs
/
ippon
/
ver
/
050
/
ippon050.lzh
/
shot.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-07-07
|
2KB
|
86 lines
/* shot.c */
#include <stdio.h>
#include <xsp2lib.h>
#include "main.h"
#include "player.h"
#include "enemy.h"
#include "shot.h"
#include "sound.h"
#define PALET_SHOT 0x0800
#define SHOT_SPEED 31
static SHOT _shot; /* ワーク */
/* ゲーム開始時に呼ばれる */
void ShotInit (void)
{
shot = &_shot;
shot->status = SHOT_STATUS_NON;
}
/* ショット出現時に呼ばれる */
void ShotAlloc (void)
{
SHOT *p = shot;
if (p->status == SHOT_STATUS_FLY)
return;
p->lx = (player->x) << 16; /* ショットの座標は自機+(0,-16) */
p->ly = (player->y + 4) << 16; /* 自機の少し上に出す */
p->pt = obj_shot;
p->info = PALET_SHOT | PRIORITY_SHOT;
p->vx = xytable[SHOT_SPEED][192].x;
p->vy = xytable[SHOT_SPEED][192].y;
p->hit_x = 3;
p->hit_y = 8;
p->erase_flag = 0;
p->enemy = NULL;
p->shot_count = 0;
p->status = SHOT_STATUS_FLY;
SoundSetSE (SE_SHOT); /* ショット発射音 */
}
/* 垂直同期ごとに呼ばれる */
void ShotMove (void)
{
SHOT *p = shot;
switch (p->status) {
case SHOT_STATUS_NON:
break;
case SHOT_STATUS_FLY:
/* 速度を足して上位ワード(固定整数部)だけ取り出す */
p->x = (p->lx += p->vx) >> 16;
p->y = (p->ly += p->vy) >> 16;
/* ショットが画面外に出たか? */
/* (画面右から出た判定と左から出た判定を1回の比較で行っている事に注目) */
if (((unsigned short) (p->x) > 256 + 16)
|| ((unsigned short) (p->y) > 256 + 16)) {
p->status = SHOT_STATUS_NON;
} else {
xobj_set_st (p);
}
break;
case SHOT_STATUS_STICK:
p->x = ((p->lx = p->enemy->lx) >> 16) + p->off_x;
p->y = ((p->ly = p->enemy->ly) >> 16) + p->off_y;
xobj_set_st (p);
break;
}
}